package com.sixth.controller;

import com.sixth.entity.Branch;
import com.sixth.entity.BranchTransfer;
import com.sixth.service.BranchService;
import com.sixth.util.CommonResult;
import com.sixth.util.TableLayUi;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @program: project01
 * @description:
 * @author: 高振杨
 * @create: 2021-12-17 19:02
 **/
@RestController
@RequestMapping("/branch")
public class BranchController {

    @Autowired
    private BranchService service;

    @RequestMapping("/findAll")
    public CommonResult findAll(){
        CommonResult result = service.findBranchAll();
        return  result;
    }

    //获取当前分店
    @RequestMapping("/getOneBranch")
    public CommonResult getOneBranch(Integer branchid) {
        System.out.println(branchid);
        return service.getOneBranch(branchid);
    }

    //修改店铺状态
    @RequestMapping("updateState")
    public CommonResult updateState(Integer id, Integer state) {
        return service.updateState(id, state);
    }
    //根据id删除
    @RequestMapping("/delete")
    public CommonResult delete(Integer id){
        return service.delete(id);
    }


    //获取分店名字
    @RequestMapping("getBranchName")
    public CommonResult getBranchName(String branchname) {
        System.out.println(branchname);
        return service.getBranchName(branchname);
    }

    @RequestMapping("/listByCondition")
    public TableLayUi listByCondition(int page, int limit, String branchname){
        return service.findEmpByCondition(page, limit, branchname);
    }

    @RequestMapping("addOrUpdateBranch")
    public CommonResult addOrUpdateBranch(Branch branch) {
        return service.addOrUpdateBranch(branch);
    }

    @RequestMapping("DZTransfer")
    public CommonResult DZTransfer(BranchTransfer branchTransfer) {
        return service.DZTransfer(branchTransfer);
    }

    //修改店长
    @RequestMapping("DZUpdate")
    public CommonResult DZUpdate(Integer branchid,Integer staffid) {
        return service.DZUpdate(branchid,staffid);
    }

}
